<template>
	<view class="page">
		<unit-div :userMsg='userMsg'></unit-div>
		<div class="myUnit">
			<uni-section class="mySection" title="我的待办" type="line"></uni-section>
			<div style="display: flex;">
				<div class="menuDiv" v-for="item in list" @click="goNav(item)">
					<div class="iconDiv" style="margin: 10px; display: inline-block;">
						<uni-icons :type="item.icon" size="30px" :color='item.color'></uni-icons>
					</div>
					<div class="textDiv">
						<div class="text">{{item.num}}</div>
						<div class="name">{{item.name}}</div>
					</div>
				</div>
			</div>
			<div style="display: flex;">
				<div class="menuDiv" v-for="item in list2" @click="scanNav(item)">
					<div class="iconDiv" style="margin: 10px; display: inline-block;">
						<uni-icons :type="item.icon" size="30px" :color='item.color'></uni-icons>
					</div>
					<div class="textDiv">
						<div class="text">{{item.num}}</div>
						<div class="name">{{item.name}}</div>
					</div>
				</div>
			</div>
		</div>
	</view>
</template>

<script>
	import {
		listOrder,changeOrder
	} from "@/api/orderMng/index.js"
	export default {
		data() {
			return {
				userMsg: {
					nickName: 'admin',
					deptName: '欢迎使用'
				},
				total:0,
				list: [{
						name: '待处理',
						num: 0,
						icon: 'notification',
						color: '#0275a1',
						url: 'orderMng/orderList'
					},
					{
						name: '已处理',
						num: 0,
						icon: 'checkbox',
						color: '#009688',
						url: 'orderMng/orderList2',
					}
				],
				list2: [
					{
						name: '扫码报工',
						icon: 'scan',
						color: '#673AB7',
						flag: 0,
					},
					{
						name: '扫码入库',
						icon: 'scan',
						color: '#795548',
						flag: 1
					}
				],
			}
		},
		created() {
			this.load()
		},
		methods: {
			goNav(e) {
				uni.navigateTo({
					url: e.url
				})
			},
			scanNav(e){
				let vm = this
				uni.scanCode({
					scanType: 'qrCode',
					success(res) {
						let result = res.result
						uni.navigateTo({
							url: '/pages/orderMng/scanDetail?flag=' + e.flag+'&result='+result
						})
					},
					fail() {
						uni.showToast({
							icon: 'none',
							title: '扫码失败'
						})
					}
				})
			},
			load(){
				let req={
					orderStatusList:[10,20],
					pageNum:1,
					pageSize:10000
				}
				listOrder(req).then(res=>{
					this.list[0].num=res.total
				})
				let req2={
					orderStatusList:[30,40,50],
					pageNum:1,
					pageSize:10000
				}
				listOrder(req2).then(res=>{
					this.list[1].num=res.total
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.grid {
		display: flex;
		background: #fff;
	}

	.grid-item {
		flex: 1;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		margin: 5px;
	}

	.grid-item2 {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		width: 25%;
		margin: 5px 0;
		position: relative;
	}

	.iconDiv {
		border-radius: 10px;
		width: 35px;
		height: 35px;
		text-align: center;
		line-height: 35px;
	}

	.numTag {
		position: absolute;
		top: 0;
		right: 0;
	}

	.menuDiv {
		flex: 1;
		height: 60px;
		background: #f3f4f5;
		display: flex;
		align-items: center;
		margin: 5px;
		border-radius: 10px;
		justify-content: center;
	}

	.menuDiv2 {
		flex: 1;
		height: 60px;
		background: #f3f4f5;
		display: flex;
		align-items: center;
		margin: 5px;
		border-radius: 10px;
		justify-content: space-evenly;
	}

	.textDiv {
		// flex: 1;
		text-align: center;
		display: inline-block;
	}

	.text {
		font-size: 20px;
		color: $u-primary;
	}

	.name {
		display: flex;
		align-items: center;
	}

	.liDiv {
		font-size: 14px;
		padding: 5px;
		color: $u-primary;
		border-bottom: 2px dashed #f3f4f5;
	}

	.tipDiv {
		font-size: 13px;
		margin-left: 3px;
	}

	.rightIcon {
		margin-left: 10px;
	}
</style>